package com.rd.student.dashuju.sunwenzhuo.day0728;

import java.io.*;
import java.util.*;

public class RandomName3 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader("all.txt"));
        String line = null;
        line = reader.readLine();

        String[] content = line.split("、");

        int n = content.length;

        System.out.println("请输入需要的人数");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        Random random = new Random();
        File file1 = new File("random.txt");
        Writer writer1 = new FileWriter(file1);

        LinkedList list = new LinkedList();


        for (int i = 0; i < num; i++) {
            int m = random.nextInt(n);

            if (list.contains(m)) {
                i--;
            } else {
                list.add(m);
                writer1.write(content[m]+" ");
            }
        }

        writer1.close();
    }
}
//}